package com.tiandao.mofang.core.util;

import com.tiandao.mofang.core.RobotSingleton;

import java.awt.*;
import java.awt.event.KeyEvent;

public class OpenBox implements Runnable{
    public static int HAO_NUM = 1;
    public static Robot robot = RobotSingleton.getInstance();
    public static Boolean flag = true;
    /**
     * 循环'8'键一秒八次
     */
    @Override
    public void run() {
        if(HAO_NUM>1){
            new Thread(new OpenBoxQHListener()).start();
        }
        start();
    }

    public static void start(){
        int i = 1;
        while (flag){
            if(i==1){
                try {
                    Thread.sleep(5000);
                } catch (InterruptedException ex) {
                    ex.printStackTrace();
                }
            }
            robot.keyPress(KeyEvent.VK_8);
            robot.keyRelease(KeyEvent.VK_8);
            try {
                Thread.sleep(125);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            i++;
        }
    }
}
